<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
error_reporting(0);
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);

?>
<table border="0" width="800" cellspacing="0" cellpadding="0">
	<tr>
		<td bgcolor="#E9E9E9" height="26">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
	  <font face="Verdana" color="#224568">Block &amp; Scheme wise cost of Water (as per PHED)</font></span></td>
	</tr>
	<tr>
	  <td bgcolor="#E9E9E9" height="26"><div align="center"><font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568">Table 11 </font></div></td>
  </tr>
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="800" cellspacing="0" cellpadding="0" height="61" bgcolor="#C5D8EB">
			
			<tr>
			  <td width="92" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Name of the Block</font></td>
			  <td width="51" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Type of the Scheme</font></td>
			  <td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana">Current Population served (2010)</font></td>
		      <td width="59" align="center"><font style="font-size: 8.5pt" face="Verdana">Water Supplied (KLD)</font></td>
		      <td width="53" align="center"><font style="font-size: 8.5pt" face="Verdana">Bill Raised (2008-09) in Lakhs Rs.</font></td>
		      <td width="65" align="center"><font style="font-size: 8.5pt" face="Verdana">Revenue Generated (2008-09) in Lakhs Rs.</font></td>
		      <td width="56" align="center"><font style="font-size: 8.5pt" face="Verdana">Total O&M cost (in Lakh Rs.)</font></td>
		      <td width="56" align="center"><font style="font-size: 8.5pt" face="Verdana">Avg. lpcd</font></td>
		      <td width="58" align="center"><font style="font-size: 8.5pt" face="Verdana">Avg. O/R Ratio</font></td>
		      <td width="76" align="center"><font style="font-size: 8.5pt" face="Verdana">Revenue/KL (Rs.)</font></td>
		      <td width="66" align="center"><font style="font-size: 8.5pt" face="Verdana">Avg. O&M Cost/KL</font></td>
			  <td width="79" align="center"><font style="font-size: 8.5pt" face="Verdana">Avg. O&M Cost/ person/ annum (Rs.)</font></td>
		  </tr>
				
		<?php
		$grandTotalScheme=0;
			while($rowReport = mysql_fetch_array($queryReport)) {
			
			
			$billPnT=getBill_water_Raise($distId,'P&T',$rowReport['block_id']);
			$billPiped=getBill_water_Raise($distId,'Piped',$rowReport['block_id']);
			$billRwss=0;//$billRwss=getBill_water_Raise($distId,'Rwss',$rowReport['block_id']);
			$Totalwater=$billPnT[0]+$billPiped[0];
			$Totalbillraised=$billPnT[1]+$billPiped[1];
			$Totalrg=$billPnT[2]+$billPiped[2];
			$Totalom=$billPnT[3]+$billPiped[3];
			$a=getPopulationSchemeBlockWise($distId,'P&T',$rowReport['block_id']);
			$b=getPopulationSchemeBlockWise($distId,'Piped',$rowReport['block_id']);
			$total_population=$a+$b;
			if($a==0)
			{
			 $avg_pnt="0";
			}else{
			$avg_pnt=number_format($billPnT[0]*1000/$a,2,'.','');}
			if($b==0)
			{
			 $avg_piped="0";
			}else{
			$avg_piped=number_format($billPiped[0]*1000/$b,2,'.','');}
			$Totalavg_piped=$avg_pnt+$avg_piped;
			if($billPnT[2]==0)
			{
			$or_ratio_pnt=0;
			}else{
			$or_ratio_pnt=number_format($billPnT[3]/$billPnT[2],2,'.','');}
			if($billPiped[2]==0)
			{
			$or_ratio_piped=0;
			}else{
			$or_ratio_piped=number_format($billPiped[3]/$billPiped[2],2,'.','');}
			$Totalor_ratio=$or_ratio_piped+$or_ratio_pnt;
			if($billPnT[0]==0)
			{
			$revenue_pnt=0;
			}else{
			$revenue_pnt=number_format($billPnT[2]*100000/$billPnT[0]/365,2,'.','');}
			if($billPiped[0]==0)
			{
			$revenue_piped=0;
			}else{
			$revenue_piped=number_format($billPiped[2]*100000/$billPiped[0]/365,2,'.','');}
			$Totalrevenue=$revenue_pnt+$revenue_piped;
			if($billPnT[0]==0)
			{
			$avg_om_pnt=0;
			}else{
			$avg_om_pnt=number_format($billPnT[3]*100000/$billPnT[0]/365,2,'.','');}
			if($billPiped[0]==0)
			{
			$avg_om_piped=0;
			}else{
			$avg_om_piped=number_format($billPiped[3]*100000/$billPiped[0]/365,2,'.','');}
			
			$Totalavg_om=$avg_om_pnt+$avg_om_piped;
			if($a==0)
			{
			$avg1_om_pnt=0;
			}else{
			$avg1_om_pnt=number_format($billPnT[3]*100000/$a/365,2,'.','');}
			if($b==0)
			{
			$avg1_om_piped=0;
			}else{
			$avg1_om_piped=number_format($billPiped[3]*100000/$b/365,2,'.','');}
			$Total_om1=$avg1_om_pnt+$avg1_om_piped;
			$grandTotalScheme+=$total_population;
			 $grandTotalwater+=$Totalwater;
			 $grandTotalbillraised+=$Totalbillraised;
			  $grandTotalrg+=$Totalrg;
			 $grandTotalom+=$Totalom;
			 $grandTotalavg_piped+=$Totalavg_piped;
			 $grandTotalor_ratio+=$Totalor_ratio;
			 $grandTotalrevenue+=$Totalrevenue;
			 $grandTotalavg_om+=$Totalavg_om;
			 $grandTotal_om1+=$Total_om1;
			?>
			<tr  bgcolor="#F9F9F9">
				<td width="94" align="center" rowspan="4" valign="top" bgcolor="#F9F9F9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport['block_name']; ?></font></td>
				<td width="49" align="center">
				<font style="font-size: 8.5pt" face="Verdana">P &amp; T</font></td>
				<td align="center" width="64"><font style="font-size: 8.5pt" face="Verdana"><?php echo getPopulationSchemeBlockWise($distId,'P&T',$rowReport['block_id']);?></font></td>
				<td align="center" width="58"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[0], 2, '.','');?></font></td>
				<td align="center" width="52"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[1], 2, '.','');?></font></td>
				<td align="center" width="65"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[2], 2, '.','');?></font></td>
				<td align="center" width="58"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[3], 2, '.','');?></font></td>
				<td align="center" width="56"><font style="font-size: 8.5pt" face="Verdana"><?php echo $avg_pnt;?></font></td>
				<td width="58" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $or_ratio_pnt;?></font></td>
			    <td width="74" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $revenue_pnt;?></font></td>
			    <td width="68" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $avg_om_pnt;?></font></td>
				<td width="78" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $avg1_om_pnt;?></font></td>
			</tr>
			<tr bgcolor="#F9F9F9">
				<td width="49" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Piped</font></td>
				<td width="64" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo getPopulationSchemeBlockWise($distId,'Piped',$rowReport['block_id']);?></font></td>
				<td width="58" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[0], 2, '.','');?></font></td>
				<td width="52" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[1], 2, '.','');?></font></td>
				<td width="65" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[2], 2, '.','');?></font></td>
				<td width="58" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[3], 2, '.','');?></font></td>
				<td width="56" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $avg_piped; ?></font></td>
				<td align="center" width="58"><font style="font-size: 8.5pt" face="Verdana"><?php echo $or_ratio_piped;?></font></td>
			    <td align="center" width="74"><font style="font-size: 8.5pt" face="Verdana"><?php echo $revenue_piped;?></font></td>
			    <td align="center" width="68"><font style="font-size: 8.5pt" face="Verdana"><?php echo $avg_om_piped;?></font></td>
				<td width="78" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $avg1_om_piped;?></font></td>
			</tr>
			<tr bgcolor="#F9F9F9">
				<td width="49" align="center">
				<font style="font-size: 8.5pt" face="Verdana">RWSS</font></td>
				<td width="64" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo "0";//getPopulationSchemeBlockWise($distId,'P&T',$rowReport['block_id']);?></font></td>
				<td width="58" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
				<td width="65" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
				<td width="58" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
				<td width="56" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
				<td align="center" width="58"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
			    <td align="center" width="74"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
			    <td align="center" width="68"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
				<td width="78" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
				<td width="78" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $billRwss;?></font></td>
			</tr>
			
			<tr>
				<td width="49" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td width="64" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $total_population;?></font></td>
				<td width="58" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalwater;?></font></td>
				<td width="52" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalbillraised;?></font></td>
				<td width="65" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalrg;?></font></td>
				<td width="58" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalom;?></font></td>
				<td width="56" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalavg_piped;?></font></td>
				<td align="center" width="58" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalor_ratio;?></font></td>
			    <td align="center" width="74" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalrevenue;?></font></td>
				<td width="78" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Totalavg_om;?></font></td>
				<td width="78" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Total_om1;?></font></td>
			</tr>
			<?php }?>
			<tr>
				<td colspan="2" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana">Grand Total</font></td>
				<td width="64" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalScheme;?></font></td>
				<td width="58" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalwater;?></font></td>
				<td width="52" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalbillraised;?></font></td>
				<td width="65" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalrg;?></font></td>
				<td width="58" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalom;?></font></td>
				<td width="56" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalavg_piped;?></font></td>
				<td width="58" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalor_ratio;?></font></td>
				<td width="74" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalrevenue;?></font></td>
				<td width="68" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalavg_om;?></font></td>
				<td width="78" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotal_om1;?></font></td>
			</tr>
		</table>		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


</body>

</html>
